//
//  AddFriendController.m
//  PaiQuan
//
//  Created by Mac on 16/7/7.
//  Copyright © 2016年 huigu. All rights reserved.
//

#import "AddFriendController.h"
#import "IphoneLinkManController.h"
@interface AddFriendController ()
@property(nonatomic,strong)NSArray *imgeArr;
@property(nonatomic,strong)NSArray *firArr;
@property(nonatomic,strong)UIView *coverView;
@end

@implementation AddFriendController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUPNav];
   
    self.imgeArr = @[@"联系人",@"邀请"];
 
    self.firArr =@[@"添加手机联系人",@"邀请好友"];
    
   
}
-(void)setUPNav{
    self.titleView.title = @" 添加好友";
    [self.titleView.btnBack setImage:PQIMG(@"back") forState:UIControlStateNormal];
    [self.titleView.btnBack setTitle:@"返回" forState:UIControlStateNormal];
    [self.titleView.btnBack setTitleColor:PQ_COLOR_YELLOW forState:UIControlStateNormal];
    

}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        
    
    UIView *headerView = [[UIView alloc] init];
    headerView.backgroundColor = PQ_COLOR_DarkGray;

    UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(10, 10, ScreenW - 20, 40)];
    searchBar.backgroundColor =[UIColor whiteColor ];
    
//    searchBar.tintColor =[UIColor whiteColor];
//    searchBar.searchBarStyle =UISearchBarStyleMinimal;
    searchBar.backgroundImage = [UIImage imageWithColor:PQ_COLOR_DarkGray frame:searchBar.frame];
    searchBar.placeholder = @"搜索 好友、俱乐部";
    [headerView addSubview:searchBar];
    
    return headerView;
    }
    return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if(section == 0){
        return RATIO(144);
    }else{
        return RATIO(12);
    }
    		
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 1;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.firArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
     static NSString *ID =@"id";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell ==nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.imageView.image = PQIMG(self.imgeArr[indexPath.section]);
        cell.textLabel.text = self.firArr[indexPath.section];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.backgroundColor = PQ_COLOR_LightGray;
      
    }
    return cell;
    
    
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        IphoneLinkManController *IponeLM = [[IphoneLinkManController alloc] init];
        [self.navigationController pushViewController:IponeLM animated:YES];
    }else{
        //创建遮罩view
       self.coverView = [[UIView alloc] init];
        self.coverView.backgroundColor =[UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
        self.coverView.frame = CGRectMake(0, 0, ScreenW, ScreenH);
        [self.view addSubview:self.coverView];
        //取消按钮
        UIButton *cancelBtn = [[UIButton alloc] init];
        
        cancelBtn.backgroundColor =[UIColor clearColor];
        
        [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
        [cancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [cancelBtn addTarget:self action:@selector(cancelBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
        [self.coverView addSubview:cancelBtn];

        [cancelBtn makeConstraints:^(MASConstraintMaker *make) {
            
            make.width.bottom.left.equalTo(self.coverView);
            make.height.equalTo(RATIO(80));
        }];
        //容器的view
        
        UIView *contentView = [[UIView alloc] init];
        
        [self.coverView addSubview:contentView];
        
        contentView.backgroundColor =PQ_COLOR_SimpleGary;
        
        [contentView makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(cancelBtn.top);
            make.width.left.equalTo(self.coverView);
            make.height.equalTo(RATIO(200));
            
            
        }];
        
        UIButton *weiXinBtn = [[UIButton alloc] init];
        [weiXinBtn setImage:[UIImage imageNamed:@"weixin"] forState:UIControlStateNormal];
       
//        [weiXinBtn setTitle:@"微信好友" forState:UIControlStateNormal];
//        weiXinBtn.titleLabel.font = [UIFont systemFontOfSize:16];
//        weiXinBtn.titleLabel.textAlignment = NSTextAlignmentCenter;//设置title的字体居中
//        [weiXinBtn setTitleColor:PQ_COLOR_LightGray forState:UIControlStateNormal];//设置title在一般情况下为白色字体
//        [weiXinBtn setTitleColor:PQ_COLOR_YELLOW forState:UIControlStateHighlighted];//设置title在button被选中情况下为灰色字体
        [weiXinBtn addTarget:self action:@selector(weixinBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
        
        [contentView addSubview:weiXinBtn];
        [weiXinBtn makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(contentView);
            make.left.equalTo(contentView.left).offset(RATIO(80));
            
        }];
        
        
        UIButton *QQBtn = [[UIButton alloc] init];
         [QQBtn addTarget:self action:@selector(QQBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
        [QQBtn setImage:[UIImage imageNamed:@"QQ"] forState:UIControlStateNormal];
        [contentView addSubview:QQBtn];
        [QQBtn makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(contentView);
            make.left.equalTo(weiXinBtn.right).offset(RATIO(120));
            
        }];

        
        
    }
    
    
}
#pragma mark --按钮的点击事件
-(void)cancelBtnDidClick{
    
    [self.coverView removeFromSuperview];
    
}
-(void)weixinBtnDidClick{
    
    
}
-(void)QQBtnDidClick{
    
    
}


#pragma mark -懒加载

    
    




@end
